package ma.umi.fs.js2a.sample;

import java.util.logging.Logger;

import ma.umi.fs.js2a.com.DigitalPin;
import ma.umi.fs.js2a.com.DigitalState;
import ma.umi.fs.js2a.com.PinMode;
import ma.umi.fs.js2a.serial.ArduinoController;
import ma.umi.fs.js2a.serial.ArduinoDevice;

public class LedBlink {

	private ArduinoController controller;
	// LED definitions
	final DigitalPin LED = DigitalPin.PIN_13;

	public LedBlink(String port) {

		ArduinoDevice device = new ArduinoDevice(port);
		System.out.println(device.toString());
		controller = new ArduinoController(device);
		device.setController(controller);
		System.out.println("start setup");

		// setup();
		controller.sendpinMode(PinMode.OUTPUT, LED);
	}

	public void blink() throws InterruptedException {
		for (int i = 0; i < 10; i++) {
			controller.senddigitalWrite(LED, DigitalState.HIGH);

			Thread.sleep(1000);

			controller.senddigitalWrite(LED, DigitalState.LOW);
			Thread.sleep(1000);

		}

	}

}
